package com.ita.util;

import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class FileUtil {

	private Properties prop = PropertiesUtil.getProp();
	String idcardPath = prop.getProperty("IDCARD_PATH");
	String imgPath = prop.getProperty("IMG_PATH");
	
	public static final String MERCHANT_PATH = "meat/image/merchant";

	public static byte[] readInputStream(InputStream inputStream)
			throws IOException {
		byte[] buffer = new byte[1024];
		int len = -1;
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		while ((len = inputStream.read(buffer)) != -1) {
			outputStream.write(buffer, 0, len);
		}
		outputStream.close();
		inputStream.close();
		return outputStream.toByteArray();
	}
	
	public static void writeFile(String pathName, byte[] databytes) {
		try {
			FileOutputStream fos = new FileOutputStream(pathName);
			fos.write(databytes);
			fos.flush();
			fos.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
